/*
    Copyright (C) 2013 maik.jablonski@jease.org

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package sample.web.person;

import java.util.List;

import jfix.db4o.Database;
import jfix.zk.ObjectTableModel;
import sample.domain.Person;

public class TableModel extends ObjectTableModel<Person> {

	public Person newObject() {
		return new Person();
	}

	public String[] getColumns() {
		return new String[] { "Login", "Firstname", "Lastname", "Birthday" };
	}

	public List<Person> getList() {
		return Database.query(Person.class);
	}

	public Object getValue(Person person, int column) {
		switch (column) {
		case 0:
			return person.getLogin();
		case 1:
			return person.getFirstname();
		case 2:
			return person.getLastname();
		case 3:
			return person.getBirthday();
		}
		return null;
	}

}
